package com.l.utils;

import com.github.binarywang.java.emoji.EmojiConverter;

/**
 * 表情处理类
 * 
 * @author Administrator
 * 
 */
public final class EmojiUtil {

	private static EmojiConverter emojiConverter = EmojiConverter.getInstance();

	/**
	 * 将emojiStr转为 带有表情的字符
	 * 
	 * @param emojiStr
	 * @return
	 */
	public static String emojiConverterUnicodeStr(String emojiStr) {
		try {
			String result = emojiConverter.toUnicode(emojiStr);
			return result;
		} catch (Exception e) {
			return emojiStr;
		}
	}

	/**
	 * 带有表情的字符串转换为编码
	 * 
	 * @param str
	 * @return
	 */
	public static String emojiConverterToAlias(String str) {
		if (str == null && str == "") {
			return str;
		} else {
			try {
				String result = emojiConverter.toAlias(str);
				return result;
			} catch (Exception e) {
				// TODO Auto-generated catch block
				return "";
			}
		}

	}

	public static void main(String[] args) {
		String str = "🐱";
		// EmojiUtil.emojiConverterToAlias("/xF0/x9F/x98/x9A");
		String s = EmojiUtil.emojiConverterToAlias(str);
		EmojiUtil.emojiConverterUnicodeStr(s);
	}

}
